package com.springcloud.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

/**
 * @Description: TODO
 * @Create by: 123
 * @Date: 2021/11/22 16:28
 */


public class JsonUtils {
    public static <T> T parseObj(String jsonStr, Class<T> tClass) {
        T result = null;
        try {
            result = JSON.parseObject(jsonStr, tClass);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public static <T> T parseType(String jsonStr, TypeReference<T> tTypeReference) {
        T result = null;
        try {
            result = JSON.parseObject(jsonStr, tTypeReference);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
